package com.company.project.web;

import com.company.project.core.Result;
import com.company.project.core.ResultGenerator;
import com.company.project.model.KrWokrdaySums;
import com.company.project.service.KrWokrdaySumsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by CodeGenerator on 2018/12/14.
 */
@RestController
@RequestMapping("/kr/wokrday/sums")
public class KrWokrdaySumsController {
    @Resource
    private KrWokrdaySumsService krWokrdaySumsService;


    @PostMapping("/add")
    public Result add(KrWokrdaySums krWokrdaySums) {
        krWokrdaySumsService.save(krWokrdaySums);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam Integer id) {
        krWokrdaySumsService.deleteById(id);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    public Result update(KrWokrdaySums krWokrdaySums) {
        krWokrdaySumsService.update(krWokrdaySums);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/detail")
    public Result detail(@RequestParam Integer id) {
        KrWokrdaySums krWokrdaySums = krWokrdaySumsService.findById(id);
        return ResultGenerator.genSuccessResult(krWokrdaySums);
    }

    @PostMapping("/list")
    public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
        PageHelper.startPage(page, size);
        List<KrWokrdaySums> list = krWokrdaySumsService.findAll();
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(pageInfo);
    }






}
